

find_package(PkgConfig REQUIRED)
set(VIDEOLIB videoReader)

add_library(${VIDEOLIB} STATIC 
            ffmVideoReader.cpp
)

target_link_libraries(${VIDEOLIB} PRIVATE 
                                avformat
                                avcodec
                                swscale
                                avutil
                                swresample   
)


set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)


set(PROJECT_SOURCES
        main.cpp
        mainWindow.cpp
        videoWidget.cpp
        ../include/mainWindow.h
        ../include/videoWidget.h
)

add_executable(videoWidget
${PROJECT_SOURCES}
)

target_link_libraries(videoWidget PRIVATE
${VIDEOLIB}
 Qt${QT_VERSION_MAJOR}::Widgets

)

set_target_properties(videoWidget PROPERTIES
    ${BUNDLE_ID_OPTION}
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

include(GNUInstallDirs)
install(TARGETS videoWidget
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
